<?php

include_once("connexion.php");

if(isset($_POST['connecter'])){
$login = $_POST['login'];
$mdp = $_POST['mdp'];


$query =  "SELECT *
		   FROM user 
		   WHERE login = '".$login."' AND mdp = '".$mdp."' ";
								   
								   
$resultat = mysqli_query($connexion, $query);


if(mysqli_num_rows($resultat) == 1){
		$user = mysqli_fetch_array($resultat); // Compte le nombre de ligne de la query
		$user ["erreur"] = "";
		$_SESSION["userId"]=$user["id"];
		echo json_encode ($user["login"]." vous etes connecter");
		header("location:".$_SESSION['url']);
	}else{
		$_SESSION = array();
		echo json_encode(array("erreur"=>"Login ou Password invalide"));
	}
}else{

include_once("authentification.php"); 

}




include_once("banniere.html");
include_once("authentification.html");
include_once("footer.html");

?>